#include <bits/stdc++.h>
// 2025/06/10
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

string a, b;

void dfs(int la, int ra, int lb, int rb){
    if (la > ra)
        return;
    int pos = la;
    while (pos <= ra && a[pos] != b[rb])
        pos++;
    cout << b[rb];
    dfs(la, pos - 1, lb, lb + pos - la - 1);
    dfs(pos + 1, ra, lb + pos - la, rb - 1);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    dfs(0, a.size() - 1, 0, b.size() - 1);
    return 0;
}